package com.BraveY.Demo07;

import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        Scanner S = new Scanner(System.in);

        System.out.println("请输入一串数字：");
        String str = S.nextLine();
        System.out.println("您输入的字符串为：" + str);

        String[] strArr = str.split(" ");
        int[] intArr = new int[strArr.length];

        for (int i = 0; i < strArr.length; i++) {
            intArr[i] = Integer.parseInt(strArr[i]);
        }
        int sum = 0;
        for (int i = 0; i < intArr.length; i++) {
            System.out.print(intArr[i] + ",");
            sum += intArr[i];
        }
        System.out.println();
        System.out.println("和：" + sum);

        int n = feibo(20);
        System.out.println("斐波数列：" + n);

        int n2 = jiecheng(10);
        System.out.println(n2);
    }

    private static int jiecheng(int i) {
        if (i == 0 || i == 1) {
            return 1;
        }
        return jiecheng(i - 1) * i;
    }

    private static int feibo(int i) {
        if (i == 1 || i == 2) {
            return 1;
        }
        return feibo(i - 2) + feibo(i - 1);

    }
}
